package com.pignest.hotel.beans;

import java.util.Date;

import com.pignest.hotel.beans.global.BaseBean;
import com.pignest.hotel.beans.global.ClientSession;
import com.pignest.hotel.system.AuthenticatorHolder;

public class Log extends BaseBean {
	private static final long serialVersionUID = 242285363015369121L;

	private String userId;
	private String userName;
	private Date time;
	private String ip;
	private String category;
	private String action;
	private String description;
	/**
	 * 记录一些id之类的, 查询时不显示, 可能在恢复数据时有用
	 * */
	private String parameter;
	
	public Log() {
	}
	
	public Log(String action) {
		this(action, null, null, null);
	}
	
	public Log(String action, String category) {
		this(action, category, null, null);
	}
	
	public Log(String action, String category, String description) {
		this(action, category, description, null);
	}
	
	public Log(String action, String category, String description, String parameter) {
		ClientSession cs = AuthenticatorHolder.getClientSession();
		if (cs != null) {
			this.userId = cs.getUserId();
			this.userName = cs.getUserName();
			this.ip = cs.getClientIP();
		} else {
			this.userName = "[系统]";
		}
		this.time = new Date();
		
		this.action = action;
		this.category = category;
		this.description = description;
		this.parameter = parameter;
	}
	
	public String getUserId() {
		return userId;
	}
	public void setUserId(String userId) {
		this.userId = userId;
	}
	public Date getTime() {
		return time;
	}
	public void setTime(Date time) {
		this.time = time;
	}
	public String getIp() {
		return ip;
	}
	public void setIp(String ip) {
		this.ip = ip;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
	public String getAction() {
		return action;
	}
	public void setAction(String action) {
		this.action = action;
	}
	public String getParameter() {
		return parameter;
	}
	public void setParameter(String parameter) {
		this.parameter = parameter;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
}
